<template>
	<view class="container">
		<view class="sticky">
			<view class="uni-flex">
				<view class="flex1">
					<uni-search-bar v-model="searchValue" class="uni-mt-10" radius="5" placeholder="自动显示隐藏" clearButton="auto" cancelButton="none" />
				</view>
				<view class="mt15">
					<button class="mini-btn" type="primary" size="mini" @confirm="search">查询</button>
				</view>
			</view>
		</view>
		<scroll-view scroll-y="true" scroll-x="false" :style="{height:scrollH+'px'}" refresher-enabled="true" :refresher-triggered="isRefreshing" @refresherrefresh="onRefresh" @scrolltolower="onLoadMore">
		<view class="pt30 pb130" v-for="item in List">
			<view class="card-list uni-flex p3020 b-dash" @tap="navgetTo('pages/schdule/sign_team_detail',item,'')">
				<image :src="item.userDetailDto.headerPic" mode="widthFix"></image>
				<view class="card-item">
					<view class="uni-flex">
						<view class="">{{item.userDetailDto.nickName}}</view>
						<view class="">
							<text class="sign-status uni-success" v-if="item.userDetailDto.sta == 'END'">已完成</text>
							<text class="sign-status uni-warning" v-if="item.userDetailDto.sta == 'PAY'">已支付</text>
							<text class="sign-status uni-default" v-if="item.userDetailDto.sta == 'CANCEL'">已取消</text>
							<text class="sign-status uni-default" v-if="item.userDetailDto.sta == 'OVER'">已评价</text>
						</view>
					</view>
					<view class="color-black mb25">
						<text class="mr50">{{item.userDetailDto.sex}}</text>
						<text>{{item.userDetailDto.age}}</text>
					</view>
					<view class="">
						<text>签名&nbsp;&nbsp;{{item.userDetailDto.signature}}</text>
					</view>
				</view>
			</view>
			<!-- 加载提示 -->
			 <view v-if="isLoading" class="tc mt100 mb100">{{loadMoreText}}</view>
		</view>
		</scroll-view>
		<!-- <view class="fixed-bottom-wrap ">
			<view class="schdule-card uni-flex">
				<view class="flex-item color-black">
					<uni-icons type="shop" size="28" color="#000"></uni-icons>
					<text>领队行程</text>
				</view>
				<view class="flex-item color-green">
					<uni-icons type="weixin" size="28" color="#37b64a"></uni-icons>
					<text>分享</text>
				</view>
				<view class="flex-item sign">
					<text>我要报名</text>
				</view>
			</view>
		</view> -->
	</view>
</template>

<script>
	import api from '@/common/api/webapi.js'; /*api*/
	export default {
		components: {
			
		},
		data() {
			const currentDate = this.getDate({
				format: true
			})
			return {
				bannerList: [{
					url: "../../static/xcimg.png"
				}, {
					url: "../../static/xcimg.png"
				}, {
					url: "../../static/xcimg.png"
				}],
				searchValue:'',
				starValue:0,
				maxStar:5,
				datetimesingle: '',
				start: Date.now(),
				end: Date.now() + 180*24*3600*1000,
				region: '香格里拉',
				citys: '[{ "name": "北京市", "cityList": [ { "name": "北京市", "districtList": ["东城区", "西城区"] } ]',
				customItem: '',
				scrollH:0,
				isRefreshing:false,
				isLoading:false,
				loadMoreText:"加载中...",
				List:[],
				travelItineraryId:'',
				param: {
					page: 1, //当前页
					limit: 10, //每页显示记录数
					PageCount: 0,
					latitude: 25.040609, //默认为昆明市经纬度坐标
					longitude: 102.712251, //默认为昆明市经纬度坐标
					cityCode:0,
					locationCityName:"",
					collectDate:"",
				},
			}
		},
		computed: {
			startDate() {
				return this.getDate('start');
			},
			endDate() {
				return this.getDate('end');
			}
		},
		watch: {

		},
		onShow() {
			// let userLoginFlag = storageUtil.getStorageData("isLogin");
			// if (userLoginFlag) {
			// 	this.getOrders();
			// }
		},
		onReady() {
			// 获取可滚动区域的高度：视口高度 - tabbar切换卡高度就是剩余的内容可滚动的。
			//如果你使用取消了原生导航栏，记着把你自定义导航栏的高度也减掉哦
			uni.getSystemInfo({
				success: (res) => {
					this.scrollH = res.windowHeight - uni.upx2px(100)
				}
			})
		},
		onRefresh() {  // 下拉刷新
			this.isRefreshing = true;
			this.param.page = 1;
			this.getPageList('onPullDownRefresh',this.travelItineraryId);
		},
		onLoadMore() {  // 上拉加载
			if (this.isLoading) return;
			this.isLoading = true;
			this.param.page = (this.param.page + 1);
			if (this.param.page > this.param.PageCount) {
				this.isLoading = true;
				this.loadMoreText = "--到底啦--"
				return;
			}
			this.getPageList('onReachBottom',this.travelItineraryId);
		},
		onLoad(option) {
			// this.checkIsLogin();
			if(option.param){
				this.travelItineraryId = JSON.parse(decodeURIComponent(option.param));
				this.getPageList('onPullDownRefresh',this.travelItineraryId);
			}
		},
		mounted(){
		},
		methods: {
			checkIsLogin() {
				// let userLoginFlag = storageUtil.getStorageData("isLogin");

				// if (!userLoginFlag || userLoginFlag == '') {
				// 	this.popShowHandle();
				// 	return;
				// }
			},
			bindDateChange: function(e) {
				this.date = e.detail.value
			},
			getDate(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();
				if (type === 'start') {
					year = year;
				} else if (type === 'end') {
					if (month > 6) {
						year = year + 1;
					}
					year = year;
				}
				month = month > 9 ? month : '0' + month;
				day = day > 9 ? day : '0' + day;
				return `${year}-${month}-${day}`;
			},
			// 城市选择器
			bindRegionChange: function(e) {
				this.region = e.detail.value;
			},
			// 星级点击事件
			starChange:function(e){
				this.starValue+1;
			},
			// 页面跳转
			navgetTo(page, param, type) {
				if (param != undefined) {
					type = type || '';
					let data = {
						data: param,
						page: type
					}
					uni.navigateTo({
						url: "/" + page + "?param=" + encodeURI(JSON.stringify(data))
					});
				} else {
					uni.navigateTo({
						url: "/" + page
					});
				}
			},
			// 获取分页列表
			getPageList(type,travelItineraryId) {
				let _this = this;
				let requestData = {
					params: {
						page: _this.param.page, //当前页
						size: _this.param.limit, //每页显示记录数
						travelItineraryId:travelItineraryId,
					}
				}
				api.leaderItineraryMemberList(requestData).then(res => {
					if (res.code === 0) {
						if (res.data.list.length > 0) {
							let pagelist = res.data.list;
							if (type == "onReachBottom") {
								_this.List = _this.List.concat(pagelist)
							} else {
								_this.List = pagelist;
							}
						}else{
							_this.List = [];
						}
					} else {}
				_this.isRefreshing = false;
				_this.loadMoreText = "";
				}).catch(function(){
					_this.isRefreshing = false;
					_this.loadMoreText = "";
				})
			
			},
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		font-size: 14px;
		line-height: 24px;
	}

	.index-swiper {
		width: 100%;
		height: 670rpx;
	}

	.index-swiper image {
		width: 100%;
		height: 100%;
		object-fit: contain;
	}
	
	.bottom-wrap{
		position: relative;
		top: -60rpx;
	}
	
	.is-flex{
		display: flex;
		align-items: center;
	}
	
	.xf-wrap {
		position: relative;
		top: -60rpx;
		overflow: hidden;
	}

	.box-shadow {
		box-shadow: 2rpx 2px 2rpx $uni-text-color-grey8;
		background-color: #ffffff;
		border-radius: 20rpx;
	}

	.xf-wrap input {
		font-weight: bold;
	}

	.uni-flex {
		display: flex;
		align-items: flex-start;
		justify-content: space-between;
	}

	.uni-row {
		flex-direction: row;
	}
	.sticky {
		height: 200rpx;
		line-height: 85rpx;
		background-color: #ffffff;
		width: 100%;
		color: #888;
		position: sticky;
		top: -1rpx;
		left: 0;
		right: 0;
		z-index: 999;
		text-align: center;
	}

	.sticky text {
		color: $uni-text-color-light-blue;
		font-weight: bold;
		padding: 10rpx 15rpx;
	}
	.sticky text.active{
		color: $uni-text-color-blue;
		border-bottom: 2px solid $uni-text-color-blue;
	}
	.card-list{
		display: flex;
		justify-content: flex-start;
		align-items: center;
		image{
			width: 170rpx;
			height: 170rpx;
		}
		.card-item{
			margin-left: 25rpx;
		}
		.card-item text{
			display: inline-block;
		}
	}
	.pb130{
		padding-bottom: calc( 130rpx + max(env(safe-area-inset-bottom),20px));
	}
	.sign-status{
		font-size: 26rpx;
		// color: #888;
		border: 1px solid #888;
		border-radius: 10rpx;
		padding: 0 15rpx;
		margin-bottom: 15rpx;
	}
	.sign-status.uni-warning{
		color: $uni-text-color-orange;
		border: 1px solid $uni-text-color-orange;
	}
	.sign-status.uni-success{
		color: $uni-text-color-green;
		border: 1px solid $uni-text-color-green;
	}
	.sign-status.uni-primary{
		color: $uni-text-color-blue;
		border: 1px solid $uni-text-color-blue;
	}
	.sign-status.uni-default{
		color: #000;
		border: 1px solid #888;
	}
	.share-reward{
		.color-black{
			display: block;
			margin-bottom: 20rpx;
		}
		.is-flex{
			align-items: flex-start;
		}
		.color-gray{
			line-height: 1.8;
			text-align: justify;
			margin-left: 20rpx;
		}
	}
	.fixed-bottom-wrap {
		position: fixed;
		z-index: 111;
		bottom: 0;
		left: 0;
		right: 0;
		background-color: #fff;
		width: 100%;
		height: calc(60rpx + max(env(safe-area-inset-bottom),20px));
		line-height: calc(60rpx + max(env(safe-area-inset-bottom),20px));
	}
	.schdule-card{
		height: calc(60rpx + max(env(safe-area-inset-bottom),20px));
		line-height: 60rpx;
		border-top: 1px solid #f8f8f8;
		padding-bottom: max(env(safe-area-inset-bottom),20px);
		.flex-item{
			width: 25%;
			text-align: center;
			line-height: 40rpx;
			padding-top: 10rpx;
		}
		.flex-item:last-child{
			width: 50%;
			padding-top: 0;
		}
		text{
			display: block;
		}
		.sign{
			height: 100%;
			color: $uni-text-color-white;
			background-color: $uni-text-color-green;
			font-size: 32rpx;
			line-height: 100%;
			text{
				line-height: 100rpx;
			}
		}
	}
	
</style>